package edu.zut.operation;

public class OperationDemo {

    public static void main(String[] args) {
        int a = 100;
        int b = 102;

        int c = a + b;//202
        int d = c - a; //102
        //取商
        int e = c / a; //2
        //取余
        int f = c % a; //2
//      算法异常   ArithmeticException: / by zero
//        int g = c / 0;
//
//        Float    0.0  无限接近0
        float h = c / 0.0f;

        System.out.println(h);

//        取商  仅限于  整数
        double i = c / 2.89;
        System.out.println("i=" + i);
        double j = i / 2;
        System.out.println("j=" + j);

        //一元运算符     -   ++ 自增1   --自减1
        System.out.println(-j);
        int k = 50;
        // ++ 自增  每次 加 1
        k = k + 1; //51
        k++;
        System.out.println("k=" + k); //52
        //1 . k = k;
        //2. k = k + 1;
        System.out.println(k++);    //52
        System.out.println("k=" + k); //53
        //++   在 后    先赋值    后运算
        //1.  m = k;
        //2. k = k + 1;
        int m = k++;
        System.out.println("m=" + m);  //53
        System.out.println("k=" + k);  //54

        // ++  在前   先运算  后赋值
        //1. k = k +1;
        //2. n = k;
        int n = ++k; //55
        System.out.println("n=" + n);
        System.out.println("k =" + k);

        //  +   在连接数字是加法  但是 连接字符串时是拼接符
        //字符串  一个字符序列集合    "  "  引用数据类型
        String p = "你好";
        System.out.println(p + 10);
        System.out.println(10 + 20 + "你好");  //30你好
        System.out.println("hello" + 20 + 30); //hello2030

        //   +=    -=     *=     /=     %=
        int x = 500;
//        x = x + 1;   //x++
        x += 1;
//        x = x + 2;
        x += 2;
        //同理   -=     *=     /=     %=














    }

}
